import http from "./http.js";
import path from "./path.js";
export function logo(){
  return http.get(path.logo);
}
//学院客服Eva
export function EvaChat(message, sessionId) {
  return http.get(path.EvaChat, {
    params: {
      message: message,
      sessionId: sessionId
    }
  });
}
export function cleanEvaChat() {
  return http.get(path.cleanEvaChat);
}

// AI对话会话管理相关接口
// 获取会话列表
export function getEvaSessions(params = {}) {
  return http.get(path.evaSessions, {
    params: {
      PageNumber: 1,
      PageSize: 50,
      ...params
    }
  });
}

// 新增会话
export function addEvaSession() {
  return http.post(path.evaAddSession);
}
//删除会话
export function deleteSession(sessionId) {
  return http.post(path.deleteSession + "?session=" + sessionId);
}

// 获取历史消息
export function deleteMessage(sessionId) {
  return http.post(path.deleteMessage+"?session="+sessionId);
}
export function getEvaHistory(sessionId, params = {}) {
  return http.get(path.evaHistory, {
    params: {
      sessionId: sessionId,
      PageNumber: 1,
      PageSize: 20,
      ...params
    }
  });
}
//登录
export function userLogin(data) {
  return http.post(path.userLogin, data);
}
//注册页面选择学院
export function rigister_Choose() {
  return http.get(path.rigister_Choose);
}
//注册页面选择专业
export function register_Choose_Major(data) {
  return http.get(path.register_Choose_Major,data);
}
//查询置顶公告
export function getTopBulletin() {
  return http.get(path.getTopBulletin);
}
export function getFristBulletin(){
  return http.get(path.getFristBulletin);
}
export function getContent(data){
  return http.get(path.getContent,data);
}
export function getBulletin(params){
  return http.get(path.getFristBulletin, { params });
}
export function getUserlist(){
  return http.get(path.getUserlist);
}
export function getMessageList(data){
  return http.get(path.getMessageList,data);
}
export function getGroupMessageList(){
  return http.get(path.getGroupMessageList);
}
export function getMySelf(){
  return http.get(path.getMySelf);
}
export function addMessage(data){
  return http.post(path.addMessage,data);
}
export function addGroupMessage(data){
  return http.post(path.addGroupMessage,data);
}
export function addlittleGroupMessage(data){
  return http.post(path.addlittleGroupMessage,data);
}
export function getUserByGroup(data){
  return http.get(path.getUserByGroup,{params: data});
}
//获取好友列表
export function getFriendList(){
  return http.get(path.getFriendList);
}
//注册
export function register(data) {
  return http.post(path.registerUser, data);
}
//添加好友
export function addFriend(data){
  return http.post(path.addFriend, data);
}
//查找用户列表
export function getUserFriendList(data){
  return http.get(path.getUserFriendList,data);
}
//查找好友
export function findFriendByEmail(data){
  return http.get(path.findFriendByEmail,data);
}
//删除好友
export function removeFriend(data){
  return http.delete(path.removeFriend, data);
}
export function postMyPicture(data){
  return http.post(path.postMyPicture, data);
}
export function alltip(params){
  return http.post(path.alltip, null,{ params });
}
export function alltipByTime(params){
  return http.post(path.alltipByTime, null,{ params });
}
export function gettip(data){
  return http.get(path.gettip,  { params: data });
}
export function addtip(data){
  const formData = new FormData();
  formData.append('TipTitel', data.TipTitel);
  formData.append('TipText', data.TipText);
  formData.append('TipPictrue', data.TipPictrue);
  formData.append('TipTypeId', data.TipTypeId);
  return http.post(path.addtip, formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

export function getMyGoodsTip(params){
  return http.post(path.getMyGoodsTip, null,{ params });
}
export function getComment(data){
  return http.get(path.getComment,  { params: data });
}
export function getSecondComment(data){
  return http.get(path.getSecondComment,  { params: data });
}
export function addComment(params){
  return http.post(path.addComment, null,{ params });
}
export function getMyTip(params){
  return http.post(path.getMyTip,null, { params });
}

export function getMyGoodTipId(){
  return http.get(path.getMyGoodTipId);
}
export function userGoods(params){
  return http.post(path.userGoods,null, { params });
}
export function cancelUserGoods(params){
  return http.post(path.cancelUserGoods,null, { params });
}
export function deptlist(){
  return http.get(path.deptlist);
}

// 获取帖子类型列表（分页）
export function getTipTypeList(params){
  return http.post(path.tiptypeList, null, { params });
}

export function searchTip(params){
  return http.post(path.searchTip,null, { params });
}

//显示所有用户
export function allUser(data){
  return http.get(path.allUser, {params: data});
}

//管理员登录
export function adminLogin(data) {
  return http.post(path.adminLogin, data);
}

export function getMyFriendResponse(){
  return http.get(path.getMyFriendResponse);
}
export function deleteFriendRequest(E){
  return http.delete(`${path.deleteFriendRequest}?E=${E}`);
}
export function addFriendRequest(params){
  return http.post(path.addFriendRequest,null, { params });
}
export function createGroup(params){
  return http.post(path.createGroup,params);
}
export function getGroupList(){
  return http.get(path.getGroupList);
}
export function searchGroupo(data){
  return http.get(path.searchGroupo, {params: data});
}
export function joinGroup(data){
  return http.post(path.joinGroup, data);
}
export function outGroup(data){
  return http.post(path.outGroup, data);
}

export function getGroupMessage(data){
  return http.get(path.getGroupMessage,data);
}

export function adminbulletinlist(data){
  return http.get(path.adminbulletinlist, {
    params: data  // 对于GET请求，参数应该放在params中
  });
}

export function adminuserlist(data) {
  return http.get(path.adminuserlist, {
    params: data  // 对于GET请求，参数应该放在params中
  });
}

export function admintipalltip(data) {
  return http.post(path.admintipalltip, null, {
    params: data
  });
}
export function addBulletin(data) {
  return http.post(path.addBulletin, null, {
    params: data
  });
}
export function admindeptlist(data){
  return http.get(path.admindeptlist, {
    params: data  // 对于GET请求，参数应该放在params中
  });
}
// 文件上传接口（POST）
// 文件上传（POST）
export function postPic(file) {
  const formData = new FormData()
  formData.append('TipPictrue', file) // 参数名必须与后端完全一致

  return http.post(path.postPic, formData, { // 直接传递 formData
    headers: {
      'Content-Type': 'multipart/form-data' // 必须显式设置
    }
  })
}

// 文件删除（DELETE）
export function deletePic(url) {
  return http.delete(path.deletePic, {
    params: { url } // 使用 params 传递 URL 参数
    // 如果后端用 @RequestBody 接收，需改为 data: { url }
  })
}

// 更新用户信息
export function updateUser(userData) {
  return http.post(path.updateUser, userData);
}

// 获取用户信息
export function getUserInfo(userEmail) {
  return http.get(path.getUserInfo, {
    params: { userEmail }
  });
}

// 增加用户积分
export function createRank(userEmail, rank) {
  return http.post(path.createRank, null, {
    params: { userEmail, rank }
  });
}

// 减少用户积分
export function downRank(userEmail, rank) {
  return http.post(path.downRank, null, {
    params: { userEmail, rank }
  });
}

// 发送邮箱验证码
export function sendEmail(receiveEmail) {
  return http.get(path.sendEmail, {
    params: { receiveEmail }
  });
}
export function getRankOfTip(params){
  return http.get(path.getRankOfTip, { params });
}

// AI 智能体管理
export function createAiApp({ appName, prompt }) {
  return http.post(path.aiCreateApp, null, {
    params: { appName, prompt }
  });
}

export function getAiAppList({ pageNum = 1, pageSize = 10 } = {}) {
  return http.get(path.aiGetAppList, {
    params: { pageNum, pageSize }
  });
}

export function getAiAppDetail(id) {
  return http.get(path.aiGetAppById, {
    params: { id }
  });
}

export function editAiApp({ id, appName, prompt }) {
  return http.post(path.aiEditApp, null, {
    params: { id, appName, prompt }
  });
}

export function startAiApp(id) {
  return http.put(path.aiStartApp, null, {
    params: { id }
  });
}

export function deleteAiApp(id) {
  return http.delete(path.aiDeleteApp, {
    params: { id }
  });
}

// 知识库管理
export function createVector(vectext) {
  return http.post(path.vecCreate, null, {
    params: { vectext }
  });
}

export function getVectorList({ pageNum = 1, pageSize = 10 } = {}) {
  return http.get(path.vecList, {
    params: { pageNum, pageSize }
  });
}

export function deleteVector(id) {
  return http.delete(path.vecDelete, {
    params: { id }
  });
}

// 知识库分片
export function getVectorShards(vectorId) {
  return http.get(path.vecShardList, {
    params: { vectorId }
  });
}

export function uploadVectorFile(vectorId, file) {
  const formData = new FormData();
  formData.append('document', file);
  return http.post(`${path.vecShardUpload}?vectorId=${vectorId}`, formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}

export function createVectorShards(vectorId, documentList) {
  return http.post(`${path.vecShardCreate}?vectorId=${vectorId}`, JSON.stringify(documentList), {
    headers: {
      'Content-Type': 'application/json'
    }
  });
}

// 智能体与知识库关联
export function connectVecApp(appId, vecId) {
  return http.post(path.vecAppConnect, null, {
    params: { appId, vecId }
  });
}

export function disconnectVecApp(appId, vecId) {
  return http.post(path.vecAppDisconnect, null, {
    params: { appId, vecId }
  });
}

export function getVecAppRelations(appId) {
  return http.get(path.vecAppRelation, {
    params: { appId }
  });
}

export function getVecAppConnectedList({ appId, pageNum = 1, pageSize = 100 }) {
  return http.get(path.vecAppConnectedList, {
    params: { appId, pageNum, pageSize }
  });
}
